{% extends myBundleName ~ ':Layout:layout.html.twig' %}

{% block title %}{{ myTitlePrefix }} Results {% endblock %}

{% block content %}
{% set ages = [ 'U10','U12','U14','U16','U19'  ]          %}
{% set genders = { 'B' : 'Boys', 'G' : 'Girls' }    %}
{% set resultsRoute = 'zayso_core_admin_schedule_results' %}
<table border="1">
    <tr>
        <td>
            <a href="{{ path('zayso_core_admin_schedule_results_excel') }}">Excel</a>
        </td>
    {% for age in ages %}
        <td align="center">{{ age }} Results</td>
    {% endfor %}
    </tr>
    {% for gender,genderDesc in genders %}
    <tr><td>{{ genderDesc }}</td>
        {% for age in ages %}
        <td>
            {% for px,py in { 'All' : '', 'A' : 'A', 'B' : 'B', 'C' : 'C' } %}
                <a href="{{ path(resultsRoute, { 'div': age ~ gender, 'pool' : py}) }}">{{ px }}</a>
            {% endfor %}
        </td>
        {% endfor %}
    </tr>
    {% endfor %}
</table> 
<p>{{ isScorer }}</p>
<div>
    {% for poolKey, pool in pools %}
    <table border = "1">
        <tr><th colspan="16">Game Pool Results - {{ poolKey }}</th></tr>
        <tr><td colspan="16">PA=Points Applied, GS=Goals Scored, PE=Points Earned, PM=Minus Points</td></tr>
        <tr>
            <td>Game</td>
            <td>Status 1</td>
            <td>Status 2</td>
            <td>PA</td>
            <td>DOW Time</td>
            <td>Field</td>
            <td>Pool</td>
            <td>Home Team</td>
            <td>GS</td>
            <td>PM</td>
            <td>PE</td>
            <td>&nbsp;</td>
            <td>PE</td>
            <td>PM</td>
            <td>GS</td>
            <td>Away Team</td>
        </tr>
        {% for game in pool.games %}
        
        <tr id="ref-sched-{{game.num}}" class="game-status-{{game.status}}">
            <td>
                <a href="{{ path('zayso_core_admin_schedule_game_report', { 'id': game.id })}}">{{ game.getNum() }}</a>
            </td>
            <td>{{ game.status         }}</td>
            <td>{{ game.reportStatus   }}</td>
            <td>{{ game.pointsApplied  }}</td>
            <td>{{ game_dow(game.date) }} {{ game_time(game.time) }}</td>
            <td>{{ game.fieldDesc      }}</td>
            <td>{{ game.pool           }}</td>
            
            {% set homeTeamRel = game.homeTeam %}
            {% set awayTeamRel = game.awayTeam %}
            {% set homeTeam    = homeTeamRel.team %}
            {% set awayTeam    = awayTeamRel.team %}
            
            <td>{{ game_team_desc3(homeTeamRel)       }}</td>
            <td>{{ homeTeamRel.report.goalsScored     }}</td>
            <td>{{ homeTeamRel.report.pointsMinus     }}</td>
            <td>{{ homeTeamRel.report.pointsEarned    }}</td>
            <td>&nbsp;</td>
            <td>{{ awayTeamRel.report.pointsEarned    }}</td>
            <td>{{ awayTeamRel.report.pointsMinus     }}</td>
            <td>{{ awayTeamRel.report.goalsScored     }}</td>
            <td>{{ game_team_desc3(awayTeamRel)       }}</td>
        </tr>
        {% endfor %}       
    </table>
    <table border = "1">
        <tr><th colspan="16">Team Pool Results - {{ poolKey }}</th></tr>
        <tr><td colspan="16">GP=Games Played, GA=Goals Allowed, YC=Yellow Cards, RC=Red Cards, SP=Sportsmanship</td></tr>
        <tr>
            <td>Pool</td>
            <td>Team</td>
            <td>PE</td>
            <td>&nbsp;</td>
            <td>PM</td>
            <td>GP</td>
            <td>GW</td>
            <td>GS</td>
            <td>GA</td>
            <td>YC</td>
            <td>RC</td>
            <td>CD</td>
            <td>SD</td>
            <td>SP</td>
        </tr>
        {% for team in pool.teams %}
        {% set report = team.report %}
        <tr>
            <td>{{ team.teamKey }}</td>                  
            <td>{{ team.parentTeamKey   }}</td>                  
            <td>{{ report.pointsEarned () }} </td>
            <td>&nbsp;</td>
            <td>{{ report.pointsMinus   }} </td>                  
            <td>{{ report.gamesPlayed   }} </td>                  
            <td>{{ report.gamesWon      }} </td>                  
            <td>{{ report.goalsScored   }} </td>                  
            <td>{{ report.goalsAllowed  }} </td>                  
            <td>{{ report.cautions      }} </td>                  
            <td>{{ report.sendoffs      }} </td>                  
            <td>{{ report.coachTossed   }} </td>                  
            <td>{{ report.specTossed    }} </td>                  
            <td>{{ report.sportsmanship }} </td>                  
        </tr>
        {% endfor %}       
    </table>
    {% endfor %}
</div>
{% endblock %}
